package com.flyzing.genl.service;

import java.io.File;
import java.util.Date;
import java.util.List;

import com.flyzing.genl.dto.BaseMapperFile;
import com.flyzing.genl.po.ColumnPO;
import com.flyzing.genl.po.TablePO;
import com.flyzing.genl.util.GenConfigHelper;
import com.flyzing.genl.util.TemplateHelper;

/**
 * @author yaoguangyao
 * @Date 2020年12月30日
 */
public class GenBaseMapperFile implements IGenFile {

	@Override
	public void generate(TablePO table, List<ColumnPO> columns) {
		String packagesMapper = GenConfigHelper.getProperty("package.mapper");
		String path = JAVA_ROOT_PATH + "/" + packagesMapper.replaceAll("\\.", "/") + "/BaseMapper.java";

		BaseMapperFile baseMapperFile = new BaseMapperFile();
		baseMapperFile.setPack(packagesMapper);
		baseMapperFile.setAuthor(AUTHOR);
		baseMapperFile.setCreateDate(DATE_FORMAT.format(new Date()));
		
		File file = new File(path);
		file.getParentFile().mkdirs();
		TemplateHelper.getInstance().process("BaseMapper", path, baseMapperFile);
	}

}
